package presentacion;

import integracion.DatabaseManager;
import integracion.TareaDAO;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import share.Tarea;

public class RevisarBitacora extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet
{
	   static final long serialVersionUID = 1L;


		protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
		{
			doAll(request, response);
		}

		protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
		{
			doAll(request, response);
		}

		private void doAll(HttpServletRequest request, HttpServletResponse response) throws IOException
		{

			if(request.getParameter("accion").equals("RevisarBitacora"))
			{
				int codigoUsuario = Integer.parseInt(request.getParameter("opcionesUsuario"));

				try
				{
					TareaDAO dao = new TareaDAO(DatabaseManager.getConnection());
					ArrayList<Tarea> lista= dao.BuscarTarea(codigoUsuario);
					request.getSession().setAttribute("lista", lista);

					response.sendRedirect("index.jsp?page=OtrosCasos/RevisarBitacora&lista="+lista);
					return;

				}
				catch (SQLException e)
				{
					e.printStackTrace();
				}

			}


		}
	}